<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>props的基本使用</title>
</head>

<body>
    <!--准备好一个容器-->
    <div id="test"></div>
    <div id="test1"></div>
    <!--引入核心库-->
    <script src="../js/react.development.js"></script>
    <!--引入react-dom支持react操纵dom-->
    <script src="../js/react-dom.development.js"></script>
    <!--引入babel用于将jsx转为js-->
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        class Person extends React.Component {
            render() {
                //console.log(this);
                const { name, age, sex } = this.props//用解构赋值来定义属性
                return (
                    <ul>
                        <li>姓名:{name}</li>
                        <li>姓名:{sex}</li>
                        <li>姓名:{age}</li>
                    </ul>
                )//运用解构赋值可以简化代码
            }
        }
        //可以在组件外传递参数
        ReactDOM.render(<Person name="新元" age="25" sex="男" />, document.getElementById('test'))
        //批量传递
        //先定义一个需要传递的对象
        const p = { name: 'xinyau', age: 22, sex: 'nan' }
        ReactDOM.render(<Person {...p} />, document.getElementById('test1'))

    </script>
</body>

</html>